<?php

namespace app\middleware;

use tinywan\JWT;

/**=========================================
 * Copyright © 2023-2024, WICMS.CN. All Rights Reserved
 * Project Name: WiCMS
 * Description: 权限控制中间件
 * Author: jason
 * Email: 52527998@QQ.COM
 * Date: 2024/9/11
 * Time: 下午5:34
 * File: app\common\middleware\Auth.php
 * =========================================
 */


class JWTAuth
{
    public function handle($request, \Closure $next)
    {
        // 添加中间件前置行为执行代码
        JWT::verify();

        $request->user      = JWT::getExtend() || [];
        $request->uid       = JWT::getCurrentId() || 0;

        $response = $next($request);

        // 添加中间件后置行为执行代码
        $request->debug = true;

        return $response;
    }

}